package handler

import (
	"github.com/name5566/leaf/gate"
	"server/game/activity"
	"server/msg/jsonData"
)

func Buy(args []interface{}) {
	m := args[0].(*jsonData.MsgBuyReq)
	a := args[1].(gate.Agent)
	ret, err := activity.Buy(m.UserId, m.ShopId)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})

	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: ret, RequestId: m.RequestId})
}
func ActivityShopInfo(args []interface{}) {
	m := args[0].(*jsonData.MsgActivityShopInfoReq)
	a := args[1].(gate.Agent)
	ret, err := activity.ShopInfo(m.UserId)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})

	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: ret, RequestId: m.RequestId})
}
func QianDao(args []interface{}) {
	m := args[0].(*jsonData.MsgQianDaoReq)
	a := args[1].(gate.Agent)
	ret, err := activity.QianDao(m.UserId)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})

	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: ret, RequestId: m.RequestId})
}
func ActivityReward(args []interface{}) {
	m := args[0].(*jsonData.MsgActivityRewardReq)
	a := args[1].(gate.Agent)
	ret, err := activity.Reward(m.UserId, m.RewardType, m.RewardId)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})

	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: ret, RequestId: m.RequestId})
}
